package com.netmi.myvideopicker;

import androidx.appcompat.app.AppCompatActivity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.netmi.myvideopicker.utils.JumpActivityUtils;
import com.netmi.myvideopicker.utils.PermissionUtil;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    private Button btSelectVideo;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        btSelectVideo = findViewById(R.id.bt_select_video);
        btSelectVideo.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        int viewId = view.getId();
        if (viewId == R.id.bt_select_video){
            //请求权限
            PermissionUtil.requirePermissions(MainActivity.this,
                    new String[]{PermissionUtil.WRITE_EXTERNAL_STORAGE,
                    PermissionUtil.READ_EXTERNAL_STORAGE,PermissionUtil.CAMERA
            }, new PermissionUtil.RequirePermissionDialogListener() {
                @Override
                public void onSuccess() {
                    JumpActivityUtils.startActivity(MainActivity.this,SelectVideoActivity.class);
                }

                @Override
                public void onFailure(String tips) {
                    Toast.makeText(MainActivity.this, "你需要存储权限才能使用", Toast.LENGTH_SHORT).show();
                    return;
                }
            });
        }
    }


}
